package com.cooliris.media;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;

public class TestDataSource implements DataSource {
	private static final String TAG = "TestDataSource";
	public TestDataSource(Context ctx) {}
	
	@Override
	public String[] getDatabaseUris() {
		Log.d(TAG, "getDatabaseUris");
		return null;
	}

	@Override
	public DiskCache getThumbnailCache() {
		Log.d(TAG, "getThumbnailCache");
		return null;
	}

	//http://hiphotos.baidu.com/tvxqsjcom/pic/item/e9460cf734f72d16342acc65.jpg
	//http://www.yhq.cn/UploadFile/shop/2011/2-26/2011226211915624431s.jpg
	//http://cache.mars.sina.com.cn/nd/bbsdigi/myphoto_d/pic/2011/03/04/2005600761_2829a9cbf4a37f176c64462282e0d9fb.jpg
	@Override
	public void loadItemsForSet(MediaFeed feed, MediaSet parentSet,
			int rangeStart, int rangeEnd) {
		Log.d(TAG, "loadItemsForSet start: " + rangeStart + ", end: " + rangeEnd);
		if (parentSet.mId == 456) {
			String[] uris = {
					"http://hiphotos.baidu.com/tvxqsjcom/pic/item/e9460cf734f72d16342acc65.jpg",
					"http://www.google.com.hk/logos/2011/berliner11-hp.png", 
					"http://www.iciba.com/images/logos/logo_cd.jpg"
			};
			for (int i = rangeStart; i < rangeEnd; i++) {
				Log.d(TAG, parentSet.mName + " add item: " + i);
				MediaItem item = new MediaItem();
				item.mId = i;
				item.mCaption = String.valueOf(i);
				item.mContentUri = uris[i%3];
				feed.addItemToMediaSet(item, parentSet);
			}
			return;
		}
		
		for (int i = rangeStart; i < rangeEnd; i++) {
			Log.d(TAG, parentSet.mName + " add item: " + i);
			MediaItem item = new MediaItem();
			item.mId = i;
			item.mCaption = String.valueOf(i);
			feed.addItemToMediaSet(item, parentSet);
		}
	}

	@Override
	public void loadMediaSets(MediaFeed feed) {
		Log.d(TAG, "loadMediaSets");
		MediaSet set = feed.addMediaSet(1234, this);
		set.mName = "test1";
		set.generateTitle(true);
		set.mId = 1234;
        set.mPicasaAlbumId = Shared.INVALID;
        
		MediaSet set2 = feed.addMediaSet(456, this);
		set2.mName = "test2";
		set2.generateTitle(true);
		set2.mId = 456;
        set2.mPicasaAlbumId = Shared.INVALID;
	}

	@Override
	public boolean performOperation(int operation,
			ArrayList<MediaBucket> mediaBuckets, Object data) {
		Log.d(TAG, "performOperation");
		return false;
	}

	@Override
	public void refresh(MediaFeed feed, String[] databaseUris) {
		Log.d(TAG, "refresh");
	}

	@Override
	public void shutdown() {
		Log.d(TAG, "shutdown");
	}
}
